package com.basketball.gym.pojo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;

import java.util.Date;
import java.sql.Timestamp;
import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.TableId;

import java.io.Serializable;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * <p>
 *
 * </p>
 *
 * @author 赵肖云
 * @since 2021-03-26
 */
@Data
@TableName("gym_calendar")
@ApiModel(value = "Calendar对象", description = "")
public class Calendar implements Serializable {
    public interface update {
    }

    private static final long serialVersionUID = 1L;

    @Min(value = 1, message = "state只能是1，2，3", groups = {update.class})
    @Max(value = 3, message = "state只能是1，2，3", groups = {update.class})
    @ApiModelProperty(value = "状态（1为空闲，2为已预定，3为被占用）")
    private Short state;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateAt;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createAt;

    @ApiModelProperty(value = "时间段ID")
    private Integer timeId;

    @ApiModelProperty(value = "日期", dataType = "java.util.Date")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date date;

    @ApiModelProperty(value = "球场ID")
    private Integer courtId;

    @ApiModelProperty(value = "日程ID")
    @NotNull(message = "id不能为空", groups = {update.class})
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty(value = "预订类型（2为半场，3为全场）")
    @TableField(exist = false)
    @NotNull(message = "type不能为空", groups = {update.class})
    @Min(value = 2, message = "type只能是2或3", groups = {update.class})
    @Max(value = 3, message = "type只能是2或3", groups = {update.class})
    private Short type;

    @ApiModelProperty(value = "是否空闲")
    @TableField(exist = false)
    private Boolean disable;

    @ApiModelProperty(value = "A半场的state")
    @TableField(exist = false)
    private Short aState;

    @ApiModelProperty(value = "B半场的state")
    @TableField(exist = false)
    private Short bState;

    @ApiModelProperty(value = "用户ID")
    private Integer userId;

    @JsonIgnore
    @ApiModelProperty(value = "全场的球场编号")
    @TableField(exist = false)
    private List<Integer> courtIdList;

    @ApiModelProperty(value = "预订用户")
    @TableField(exist = false)
    private User user;

    public Calendar() {
    }

    public Calendar(Integer timeId, Date date, Integer courtId) {
        this.timeId = timeId;
        this.date = date;
        this.courtId = courtId;
    }

    public Calendar(Integer timeId, Date date, Integer courtId, Short state,Integer userId) {
        this.state = state;
        this.timeId = timeId;
        this.date = date;
        this.courtId = courtId;
        this.userId=userId;
    }
}
